import 'package:x3_base_core/x3_base_core.dart';

class BaseUrlLauncherUtil {

  /// 打开网址
  static Future<bool> url(String url) async {
    if (await canLaunch(url)) {
      return await launch(url);
    } else {
      throw '$url 失效';
    }
  }

  /// 呼叫电话
  static Future<bool> tel(String tel) async {
    return BaseUrlLauncherUtil.url('tel:$tel');
  }

  /// 发短信
  static Future<bool> sms(String sms) async {
    return BaseUrlLauncherUtil.url('sms:$sms');
  }

  /// 发邮件
  static Future<bool> mail(String email) async {
    return BaseUrlLauncherUtil.url('mailto:$email');
  }

}
